package com.herench.bs.handler;

import com.herench.bs.agent.IPersonAgent;
import com.herench.bs.annotation.Handler;
import com.herench.bs.support.AbstractMessageHandler;
import com.herench.bs.support.RequestMessage;
import com.herench.bs.support.ResponseMessage;
import org.springframework.stereotype.Component;

import java.util.Map;

@Component
@Handler(code = "100500" ,name="修改就诊人")
public class UpdatePersonNameHandler extends AbstractMessageHandler {
    @Override
    protected ResponseMessage innerHandler(RequestMessage requestMessage) throws Exception {
        ResponseMessage responseMessage = new ResponseMessage(requestMessage.getId());
        // 就诊人身份证
        String personId = requestMessage.getArgsPropertyStringValue("personId");
        // 就诊人手机
        String phone = requestMessage.getArgsPropertyStringValue("phone");
        // 就诊人姓名
        String name = requestMessage.getArgsPropertyStringValue("name");

        IPersonAgent agent = getCleverClinicContext().getApplicationContext().getBean(IPersonAgent.class);
        Map<String, Object> res = agent.updatePersonName(personId,phone,name);

        responseMessage.setData(res);
        getPropertiesFromInvokerResultMap(responseMessage, res);
        return responseMessage;
    }
}

